﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls;
using CompanyBussiness;

namespace Website
{
    public partial class MasterCenter : System.Web.UI.MasterPage
    {
        LanguagesManagement languageMana = new LanguagesManagement();
        CompanyBussiness.Language language;
        CompanyBussiness.TagTranslation tag;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies[CONST.COOKIES_LANGUAGE] == null)
            {
                Session[CONST.SESSION_LANGUAGE] = "";
                language = languageMana.GetLanguageByCode("vi-VN");
            }
            else
            {
                Session[CONST.SESSION_LANGUAGE] = Request.Cookies[CONST.COOKIES_LANGUAGE][CONST.COOKIES_LANGUAGE_ID];
                language = languageMana.GetLanguageByID(int.Parse(Session[CONST.SESSION_LANGUAGE].ToString()));
            }
            lnkLogin.Text = languageMana.GetTagValueByLanguageIDandTagName("lnkLogin", language.LanguagesID);
            lnkRegister.Text = languageMana.GetTagValueByLanguageIDandTagName("lnkRegister", language.LanguagesID);
        }

        protected void lnkLogin_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/admin/Login.aspx");
        }

        protected void lnkRegister_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Dang_ky.html");
        }

        protected void btnTV_Click(object sender, EventArgs e)
        {
            language = languageMana.GetLanguageByCode("vi-VN");
            Response.Cookies[CONST.COOKIES_LANGUAGE][CONST.COOKIES_LANGUAGE_ID] = "" + language.LanguagesID;

            Response.Redirect("~/Hem.html");
        }

        protected void btnEN_Click(object sender, EventArgs e)
        {
            language = languageMana.GetLanguageByCode("en-US");
            Response.Cookies[CONST.COOKIES_LANGUAGE][CONST.COOKIES_LANGUAGE_ID] = "" + language.LanguagesID;

            Response.Redirect("~/Hem.html");
        }
    }
}